import { defineStore } from "pinia";
import {ref} from "vue"

export const useUserStore = defineStore(
  "user",
  () => {
    const token = ref("")
	const nickName = ref('')
	const avatar = ref('0b2af875-2045-4be0-88cb-c6d53c395a64')
	const userId = ref('')
	const followers = ref([])
	const addFollow = (id)=>{
		followers.value.push(id)
	}
	const unFollow = (id)=>{
		followers.value = followers.value.filter(x=>x!=id)
	}
    return { token,nickName,avatar,userId,followers,addFollow,unFollow };
  },
  {
    unistorage: true, // 开启后对 state 的数据读写都将持久化
  },
);